import sys
sys.path.append("..")
from Config import config
import nni
import torch


def get_default_parameters():
    # 关键参数，包括要调参的参数
    params = \
    {
        # decareSample + lightGCN + bpr
        "device": torch.device('cuda:1' if torch.cuda.is_available() else "cpu"),
        "checkpoints_path": "/data/tshuang/Projects/lightGCN/Rec_SAUC/checkpoints",
        "sample_way": "user_decare",    # [all_pos_random, user_decare]
        "model": 'lgn',  # [mf, lgn, lgn_hash]
        "loss": 'bpr',  # [bce, bpr, sauc_for_sample, sauc_for_user]

        "is_use_early_stop": True,
        "TRAIN_epochs": 1000,
        "weight_decay": 0.0001,
        'lr': 0.001,
        'batch_size': 2**18,    # 2048
    }
    return params


if __name__ == "__main__":
    '''
    仅供nni测试使用
    '''
    from main import main
    try:
        # get parameters form tuner
        tuner_params = nni.get_next_parameter()
        config.update(get_default_parameters())
        config.update(tuner_params)
        # log_file_name = params["project_name"] + "_" + current_time + ".log"
        # logger = logCof(logger, "../log/", log_file_name)
        # logger.info(params)
        main(config)
    except Exception as exception:
        # logger.exception(exception)
        raise